import process from 'process'

export class IParams {
    pipelineID!: number

    pipelineName!: string

    buildNumber?: number

    workSpace!: string

    projectDir!: string

    buildJobID!: number

    regionID!: string

    domestic!:boolean

    USE_ACR_EE!:boolean

    minReadyInstanceType!:string

    enableGreyTagRoute?:string

    waitTimeInBatch?:string

    ACR_EE_ID?:string

    BatchWaitTime!:string

    APPLICATION_ID!:string

    ARTIFACT?:string

    PACKAGE!:string

    StrategyType!:string

    GrayNumber?:string

    Batch!:string

    ReleaseType!:string

    minReadyInstances?:string

    minReadyInstanceRatio?:string

    CHANGE_ORDER_ID?:string

    APP_NAME?:string


}

export function getParams(): IParams {
    let params = new IParams()
    params.pipelineID = Number(process.env.PIPELINE_ID)
    params.pipelineName = process.env.PIPELINE_NAME as string
    params.buildNumber = Number(process.env.BUILD_NUMBER)
    params.workSpace = process.env.WORK_SPACE as string
    params.projectDir = process.env.PROJECT_DIR as string
    params.buildJobID = Number(process.env.BUILD_JOB_ID)
    params.regionID = process.env.REGION_ID as string
    params.domestic = process.env.PIPELINE_LOCALE == 'zh_CN'
    params.USE_ACR_EE = process.env.USE_ACR_EE == 'true'
    params.minReadyInstanceType = process.env.minReadyInstanceType || 'byNumber'
    params.enableGreyTagRoute = process.env.enableGreyTagRoute
    params.waitTimeInBatch = process.env.waitTimeInBatch
    params.ACR_EE_ID = process.env.ACR_EE_ID
    params.BatchWaitTime = process.env.BatchWaitTime || '0'
    params.APPLICATION_ID = process.env.APPLICATION_ID as string
    params.ARTIFACT = process.env.ARTIFACT
    params.PACKAGE = process.env.PACKAGE as string
    params.StrategyType = process.env.StrategyType as string
    params.GrayNumber = process.env.GrayNumber || '1'
    params.Batch = process.env.Batch as string
    params.ReleaseType = process.env.ReleaseType as string
    params.minReadyInstances = process.env.minReadyInstances || '1'
    params.minReadyInstanceRatio = process.env.minReadyInstanceRatio || '10'
    params.CHANGE_ORDER_ID = process.env.CHANGE_ORDER_ID
    params.APP_NAME = process.env.APP_NAME

    return params
}